package com.czy.workflow.core.listener;

import com.czy.workflow.core.context.FlowContext;
import com.czy.workflow.core.model.TaskInfo;


public class FlowListenerNotify implements FlowListener {

    private FlowContext flowContext;



    @Override
    public void before(TaskInfo taskInfo, boolean success) {
        //处理非主要功能的异常，防止影响主干任务
        try{
            for(FlowListener listener : flowContext.getListenerList()){
                listener.before(taskInfo, success);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @Override
    public void after(TaskInfo taskInfo, boolean success) {
        //处理非主要功能的异常，防止影响主干任务
        try{
            for(FlowListener listener : flowContext.getListenerList()){
                listener.after(taskInfo, success);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }


    public void setFlowContext(FlowContext flowContext) {
        this.flowContext = flowContext;
    }
}
